package com.qd.panda.card;

import com.qd.common.panda.domain.entity.card.CardInfoDTO;
import com.qd.panda.service.card.CardInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 优惠券/WEB_券信息
 *
 * @author sjk
 */
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/sys/cardInfo/")
@Slf4j
public class CardInfoController {
    private final CardInfoService cardInfoService;

    /**
     * 获取券信息
     *
     * @param id 主键
     * @return 记录
     */
    @GetMapping(value = "/getById")
    public CardInfoDTO getById(@Validated @NotBlank(message = "ID不能为空") String id) {
        return cardInfoService.getByIdDto(id);
    }

    /**
     * 券信息列表
     *
     * @param dto 查询参数以及页数和每页显示条数
     * @return 列表信息
     */
    @GetMapping(value = "/getList")
    public List<CardInfoDTO> getList(CardInfoDTO dto) {
        return cardInfoService.getListDto(dto);
    }
}